Refactor Database Initialization for early schema initialization#2762
Open
lbsekr wants to merge 5 commits into
Open
Refactor Database Initialization for early schema initialization#2762lbsekr wants to merge 5 commits into
lbsekr wants to merge 5 commits into
Conversation
ensures database initializing is done before springboot context refresh ref: EXPOSED-1004
ensures database initializing is done before springboot context refresh ref: EXPOSED-1004
ref: EXPOSED-1004
ref: EXPOSED-1004
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary of the change: Migrate DatabaseInitializer from ApplicationRunner to a new initialization Point after the Database::connection is done to ensure database schema creation occurs before the application context refresh completes, preventing race conditions with database-dependent beans. Also allowing other non-spring application to apply ddl-auto generation.
Detailed description:
@PostConstructmethods, InitializingBean implementations, or repositories that validate schema on startup) attempt to access tables before the schema has been created. By moving initialization earlier in the lifecycle, immediately after Database-Connection instantiation but before it is injected into dependent it is ensured that the schema exists before any database access occursrefresh, replacing it with a mechanism that triggers during the early bean initialization phase
Type of Change
Please mark the relevant options with an "X":
Updates/remove existing public API methods:
Affected databases:
Checklist
Related Issues
Ref